﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace LuanVanProject
{
    /// <summary>
    /// Interaction logic for WebControl.xaml
    /// </summary>
    public partial class WebControl : UserControl
    {
        public WebControl()
        {
            InitializeComponent();
        }

        private void textBox1_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
            {
                webBrowser.Navigate("http://" + addressBar.Text);
               
            }
        }
        public void Navigate(string url)
        {
            webBrowser.Navigate("http://" + url);
        }
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                webBrowser.GoBack();
            }
            catch { }
        }

        private void button2_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                webBrowser.GoForward();
            }
            catch { }
        }

        private void webBrowser_Navigated(object sender, NavigationEventArgs e)
        {
            addressBar.Text = e.Uri.ToString();
        }

        private void addressBar_TextChanged(object sender, TextChangedEventArgs e)
        {
            App.currentUrl = addressBar.Text;
        }
    }
}
